FROM soxueren/tomcat:9.0-jre8-alpine

ENV DATA_DIR=/root/data
ENV PLUGINS_DIR=/root/plugins
ENV GDAL_DATA=/usr/share/gdal

ENV CATALINA_HOME=/usr/local/tomcat
ENV TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib
ENV LD_LIBRARY_PATH=/usr/lib:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/local/tomcat/native-jni-lib
ENV PATH=$PATH:$CATALINA_HOME/bin

#install gdal library
COPY --from=soxueren/busybox-gdal:2.2.0-alpine /usr/bin/* /usr/bin/
COPY --from=soxueren/busybox-gdal:2.2.0-alpine /usr/lib/* /usr/lib/
COPY --from=soxueren/busybox-gdal:2.2.0-alpine /usr/share/* /usr/share/
COPY --from=soxueren/busybox-gdal:2.2.0-alpine /usr/include/* /usr/include/
COPY --from=soxueren/busybox-gdal:2.2.0-alpine /usr/lib/jvm/java-1.8-openjdk/jre/lib/ext/*.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/ext/


ADD ./setenv.sh /usr/local/tomcat/bin/
RUN chmod +x /usr/local/tomcat/bin/setenv.sh

ADD target/geoserverplus.war /usr/local/tomcat/webapps/

EXPOSE 8080

CMD ["/bin/sh", "/usr/local/tomcat/bin/catalina.sh" , "run"]
